<?php
/*
authored by Josh Fraser (www.joshfraser.com)
released under Apache License 2.0

Maintained by Alexander Makarov, http://rmcreative.ru/

$Id$
*/
require_once("DbHelper.php");

$list=DbHelper::articlelist();
$count = sizeof($list);
$index=1;
 foreach($list as $item)
 {
    echo $index.'/'.$count.'\n';
    if (preg_match_all('~<img[\s\S]*?\ssrc=([\""\'])([^\""\']+?)\1.*?>~i', $item['content'], $imgs)) {
        if (sizeof($imgs[2])>0) {
          $item["pic"]= $imgs[2][0];
          $item->update();
        }
    }
    $index++;
 }